<?php get_backend_header() ?>

<div class="line">
	<h2 class="unit title">Feeds</h2>
</div>

<?php get_message(); ?>

<div class="buttons">
        <button id="void_temp" name="void_temp">Void all temporary orders?</button> |
        <button id="void_ready" name="void_ready">Void all ready orders?</button>
</div>

<fieldset><legend>Temporary Order</legend>
<div class ="clear"></div>

        <div class="line">
            <div id ="temp" class="field bold">
                You have <u><?php echo $temp_order_count; ?></u> temporary order(s).
            </div>
        </div>
</fieldset>

<fieldset><legend>Ready for delivery</legend>
<div class ="clear"></div>

        <div class="line">
            <div  id ="ready" class="field bold">
                You have <u><?php echo $ready_order_count; ?></u> ready for delivery order(s).
            </div>
        </div>
</fieldset>


<script type="text/javascript">

if ($('.msg').not(':hidden')) {
    setTimeout(function() {
      $('.msg').fadeOut("slow");
    }, 5000);
}

var auto_refresh1 = setInterval(
function ()
{
    $('#temp').load(siteUrl + 'admin/temp_count').fadeOut("slow", function () {
            $("#temp").fadeIn(100);
    });
}, 10000); // refresh every 10000 milliseconds

var auto_refresh2 = setInterval(
function ()
{
    $('#ready').load(siteUrl + 'admin/ready_count').fadeOut("slow", function () {
            $("#ready").fadeIn(100);
    });
}, 10000); // refresh every 10000 milliseconds

$('#void_temp').button().click(function(e) {
   $(this).removeClass('ui-state-focus');
   var code = '<span class="icon icon-info"></span><span>Void all temporary orders? Are you sure you want to continue?</span>';
   $('#ddialog').removeClass('hidden');
    $('#ddialog').attr('title', 'Void Order').html(code);
    $('#ddialog').dialog({
            resizable: false,
            height: 'auto',
            width: 'auto',
            modal: true,
            buttons: {
                    'Ok': function() {
                        window.location = siteUrl + 'orders/void_temp/';
                    },
                    'Cancel': function() {
                        $(this).dialog('destroy');
                    }
            },
            close: function() {
                    $(this).dialog('destroy');
            }
    });
})
;
$('#void_ready').button().click(function(e) {
    $(this).removeClass('ui-state-focus');
   var code = '<span class="icon icon-info"></span><span>Void all ready orders? Are you sure you want to continue?</span>';
   $('#ddialog').removeClass('hidden');
    $('#ddialog').attr('title', 'Void Order').html(code);
    $('#ddialog').dialog({
            resizable: false,
            height: 'auto',
            width: 'auto',
            modal: true,
            buttons: {
                    'Ok': function() {
                        window.location = siteUrl + 'orders/void_ready/';
                    },
                    'Cancel': function() {
                        $(this).dialog('destroy');
                    }
            },
            close: function() {
                    $(this).dialog('destroy');
            }
    });
});

</script>

<?php get_backend_footer(); ?>
